CLS Statement ---------------------------------------------------------------------------- Action Clears various parts of the display screen. Syntax CLS -{ 0 | 1 | 2}- Remarks There are several ways to use the CLS statement, as described in the following table. ----------------------------------------------------------------------------- Statement Condition Operations performed ---------------------------------------------------------------------------- CLS Graphics-screen mode no Clears default graphics user-defined graphics viewport viewport; regenerates bottom text line; returns cursor to the upper-left corner of the screen. Graphics-screen mode Clears user-defined graphics user-defined viewport viewport; does not regenerate bottom text line; does not return the cursor to the upper-left corner of the screen. In screen mode 0 (text mode) Clears text viewport; regenerates bottom text line; Statement Condition Operations performed ---------------------------------------------------------------------------- regenerates bottom text line; returns the text cursor to the upper-left corner of the screen. CLS 0 Any screen mode, combination Clears the screen of all text of viewports and graphics, except bottom text line; clears graphics viewport; regenerates bottom text line; returns the cursor to the upper-left corner of the screen. CLS 1 Graphics-screen mode with no Clears default graphics user-defined graphics viewport viewport; does not clear text viewport; regenerates bottom text line; returns the cursor to upper-left corner of the screen. Statement Condition Operations performed ---------------------------------------------------------------------------- Graphics-screen mode with Clears user-defined graphics user-defined graphics viewport viewport; does not clear text viewport; does not regenerate bottom text line; does not return the cursor to the upper-left corner of the screen. In screen mode 0 (text mode) Has no effect. CLS 2 Any screen mode Clears the text viewport (even if the user-defined text viewport includes the bottom line of text, it will not be cleared); does not clear the graphics viewport; does not regenerate the bottom text line; returns the cursor to upper-left corner of the screen. Statement Condition Operations performed ---------------------------------------------------------------------------- upper-left corner of the screen. The behavior of a particular CLS statement depends on. - The CLS statement argument. 0, 1, 2, or none. - The current screen mode. - Whether a VIEW statement has been executed that has changed the graphics viewport from the default of the entire screen. - Whether a VIEW PRINT statement has been executed that established a user-defined viewport. - Whether a KEY ON statement has been executed that established the bottom text line as a list of function-key assignments. The bottom line on the screen may be 25, 30, 43, or 60, depending upon the current screen mode. The following fundamentals about the graphics and text viewports determine how the CLS statement works. - Screen mode 0 has only a text viewport. All other screen modes have both a text and graphics viewport. - The default graphics viewport is the entire screen. - The default text viewport is the entire screen, except for the bottom line of text. - After a user-defined graphics viewport (or "clipping region") has been established by execution of a VIEW statement, it is reset to the default by execution of any of these statements. VIEW without arguments; CLEAR; any SCREEN statement that changes the screen resolution. - After a user-defined text viewport has been established by execution of a VIEW PRINT statement, it is reset to the default by execution of either a VIEW PRINT statement without arguments, or any text-oriented statement, such as WIDTH, that changes the number of text columns or text lines on the screen. - If the KEY ON statement has been executed and the CLS statement regenerates the bottom screen line, the CLS statement regenerates the function-key assignment list. If the KEY ON statement has not been executed, the CLS statement generates a line of blank characters. See Also VIEW, VIEW PRINT, WINDOW Example The following example draws random circles in a graphics viewport and prints to a text viewport. The graphics viewport is cleared after 30 circles have been drawn. The program clears the text viewport after printing to it 45 times. RANDOMIZE TIMER SCREEN 1 ' Set up a graphics viewport with a border. VIEW (5,5)-(100,80),3,1 ' Set up a text viewport. VIEW PRINT 12 TO 24 LOCATE 25,1 . PRINT "Press any key to stop." ' Outside the text viewport. Count=0 DO CIRCLE (50,40),INT((35-4) * RND + 5),(Count MOD 4) ' Clear graphics viewport every 30 times. IF (Count MOD 30)=0 THEN CLS 1 PRINT "Hello. "; ' Clear text viewport every 45 times. IF (Count MOD 45)=0 THEN CLS 2 Count=Count+1 LOOP UNTIL INKEY$ <> ""